package org.java.base.idea;

/**
 * 整理了关于equal和==的区别
 *
 * @Author idea
 * @Date created in 6:50 下午 2020/5/1
 */
public class EqualsDemo {

    public static void test1(){
        String str1=new String("test");
        String str2=new String("test");
        System.out.println(str1.equals(str2));

        String str3=str1;
        String str4=str2;
        System.out.println(str3.equals(str4));

        String str5=str1;
        String str6=str1;
        System.out.println(str5.equals(str6));

        Integer a =1;
        Integer b =1;

        System.out.println(a.equals(b));
        System.out.println(a.intValue()==b.intValue());



        Long c =1L;
        Integer d = 1;
        System.out.println(c.intValue()==d.intValue());
        System.out.println(c.equals(d));


        Integer i1=new Integer(1218);
        Integer i2=new Integer(1218);
        System.out.println(i1.equals(i2));

        System.out.println(i1.equals(i2));

    }


    public static void main(String[] args) {
        System.out.println("this is test");
        test1();
    }
}
